import 'package:get/get.dart';
import 'package:vape_xe/middlewares/middlewares.dart';
import 'package:vape_xe/modules/web/index.dart';
import 'package:vape_xe/modules/withdraw/index.dart';

import '../modules/home/index.dart';
import '../modules/login/index.dart';
import '../modules/profile/index.dart';
import '../modules/splash/index.dart';

part 'app_routes.dart';

class AppPages {
  AppPages._();

  static const INITIAL = Routes.EARN;

  /// 似乎是已第一个GetPage作为启动页
  static final routes = [
    GetPage(
      name: _Paths.splash,
      page: () => const SplashPageView(),
      binding: SplashPageBinding(),
      preventDuplicates: true,
    ),
    GetPage(
      name: _Paths.home,
      page: () => const HomeView(),
      binding: HomeBinding(),
      preventDuplicates: true,
      participatesInRootNavigator: true,
      children: [
        GetPage(
          name: _Paths.earn,
          page: () => const EarnView(),
          binding: EarnBinding(),
          transition: Transition.fade,
          middlewares: [EnsureAuthMiddleware()],
        ),
        GetPage(
          name: _Paths.playground,
          page: () => PlayGroundView(),
          transition: Transition.fade,
          middlewares: [EnsureAuthMiddleware()],
        ),
      ],
    ),
    GetPage(
      name: _Paths.scan,
      page: () => const ScanView(),
      binding: ScanBinding(),
      middlewares: [EnsureAuthMiddleware()],
    ),
    GetPage(
      name: _Paths.web_view,
      page: () => const WebViewPage(),
      binding: WebViewBinding(),
    ),
    GetPage(
        name: _Paths.profile,
        page: () => const ProfileView(),
        binding: ProfileBinding(),
        preventDuplicates: true,
        middlewares: [
          EnsureAuthMiddleware()
        ],
        //防止重复
        children: [
          GetPage(
            name: _Paths.account_info,
            page: () => const AccountInfoView(),
            binding: AccountInfoBinding(),
            children: [
              GetPage(
                name: _Paths.account_info_detail,
                page: () => const AccountInfoDetailView(),
                binding: AccountInfoDetailBinding(),
              ),
              GetPage(
                name: _Paths.account_info_change,
                page: () => const AccountInfoChangeView(),
                binding: AccountInfoChangeBinding(),
                children: [
                  GetPage(
                    name: _Paths.account_info_change_code,
                    page: () => const ChangeVerificationCodeView(),
                    binding: ChangeVerificationCodeBinding(),
                  ),
                  GetPage(
                    name: _Paths.account_info_change_result,
                    page: () => const ChangeSuccessView(),
                    binding: ChangeSuccessBinding(),
                  ),
                ],
              ),
            ],
          ),
          GetPage(
            name: _Paths.team,
            page: () => const TeamView(),
            binding: TeamBinding(),
          ),
          GetPage(
            name: _Paths.rewards,
            page: () => const RewardsView(),
            binding: RewardsBinding(),
          ),
          GetPage(
            name: _Paths.proceeds,
            page: () => const ProceedsView(),
            binding: ProceedsBinding(),
          ),
        ]),
    GetPage(
      name: _Paths.energy,
      page: () => const EnergyView(),
      binding: EnergyBinding(),
      children: [
        GetPage(
          name: _Paths.upgrade,
          page: () => const UpgradeView(),
          binding: UpgradeBinding(),
        ),
      ],
    ),

    ///登录注册
    GetPage(
        name: _Paths.sign_in,
        page: () => const SignInView(),
        binding: SignInBinding(),
        middlewares: [EnsureNotAuthedMiddleware()]),
    GetPage(
        name: _Paths.sign_up,
        page: () => const SignUpView(),
        binding: SignUpBinding(),
        middlewares: [EnsureNotAuthedMiddleware()]),
    GetPage(
      name: _Paths.forget,
      page: () => const ForgetView(),
      binding: ForgetBinding(),
      middlewares: [EnsureNotAuthedMiddleware()],
      children: [
        GetPage(
          name: _Paths.forget_code,
          page: () => const VerificationCodeView(),
          binding: VerificationCodeBinding(),
        ),
        GetPage(
          name: _Paths.forget_password,
          page: () => const PasswordView(),
          binding: PasswordBinding(),
        ),
      ],
    ),

    ///提现
    GetPage(
      name: _Paths.withdraw,
      page: () => const WithdrawView(),
      binding: WithdrawBinding(),
      middlewares: [EnsureAuthMiddleware()],
      children: [
        GetPage(
            name: _Paths.withdraw_address,
            page: () => const WithdrawAddressView(),
            binding: WithdrawAddressBinding(),
            children: [
              GetPage(
                name: _Paths.withdraw_address_new,
                page: () => const WithdrawAddressNewView(),
                binding: WithdrawAddressNewBinding(),
              ),
            ]),
        GetPage(
          name: _Paths.withdraw_code,
          page: () => const WithdrawVerificationCodeView(),
          binding: WithdrawVerificationCodeBinding(),
        ),
        GetPage(
          name: _Paths.withdraw_list,
          page: () => const WithdrawListView(),
          binding: WithdrawListBinding(),
        ),
        GetPage(
          name: _Paths.withdraw_details,
          page: () => const WithdrawDetailsView(),
          binding: WithdrawDetailsBinding(),
        ),
      ],
    ),
  ];
}
